package com.yuwei.goods_detail.adapter

import android.graphics.Color
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.yuwei.goods_detail.R

class AttrAdapter: BaseQuickAdapter<String, BaseViewHolder>(
    R.layout.item_attr
) {
    private var mPosition = -1
    fun setPosition(position: Int) {
        mPosition = position
    }
    override fun convert(holder: BaseViewHolder, item: String) {
        if(mPosition == holder.adapterPosition ){
            holder.setText(R.id.attr_tv,item)
                .setBackgroundResource(R.id.attr_tv,R.drawable.item_attr_selected_bg)
             .setTextColor(R.id.attr_tv,Color.parseColor("#FFFFFF"))
        }else{
            holder.setText(R.id.attr_tv,item)
                .setBackgroundResource(R.id.attr_tv,R.drawable.item_attr_un_selected_bg)
              .setTextColor(R.id.attr_tv,Color.parseColor("#000000"))
        }
    }
}